<template>
	<view>
		<view class="m-list" v-if="list.length > 0">
			<view class="m-item" v-for="(item,index) in list" :key="index" @click="selectFun(item)">
				<view class="m-item-left">
					<view class="m-item-font1">
						<text class="m-item-tip" v-if="item.if_default == 1">默认</text>
						<text>{{item.areaName}}{{item.address}}</text>
					</view>
					<view class="m-item-font2">
						<text>{{item.name}}</text>
						<text class="u-m-l-10">{{item.phone}}</text>
					</view>
				</view>
				<view class="m-item-right" v-if="type == 'list'" @click.stop="to_link('/pages2/shop-address-add/shop-address-add?type=edit&id='+item.id)">
					<text>编辑</text>
				</view>
			</view>
		</view>
		<view style="padding-top: 300rpx;" v-else>
			<u-empty text="没有收货地址" mode="address"></u-empty> 
		</view>
		<view class="m-bottom">
			<view class="m-btn" @click="to_link('/pages2/shop-address-add/shop-address-add')">
				<text>新建收货地址</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type:'list',
				list:[]
			}
		},
		onLoad(opt) {
			this.type = opt.type || 'list'
		},
		onShow(){
			this.getListFun()
		},
		methods: {
			selectFun(item){
				if(this.type == 'select'){
					uni.$emit('selectAddrFn',item)
					this.to_back()
				}
			},
			getListFun(){
				this.$http.getJson('userAddress_lists',{page:1,pagenum:50}).then(res=>{
					if(res.code == 1){
						this.list = res.data || []
					}
				})
			}
		}
	}
</script>

<style lang="scss">
page{
	background: #f6f6f6;
	padding-bottom: 230rpx;
}
.m-bottom{
	position: fixed;
	bottom: 100rpx;
	width: 750rpx;
	display: flex;
	justify-content: center;
	.m-btn{
		display: flex;
		justify-content: center;
		align-items: center;
		width: 702rpx;
		height: 104rpx;
		background: #D3A358;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		font-size: 32rpx;
		color: #fff;
	}
}
.m-list{
	background: #fff;
	padding-left: 25rpx;
	.m-item{
		display: flex;
		padding: 30rpx 0;
		border-bottom: 1px solid #E5DCCD;
		.m-item-left{
			flex: 1;
			.m-item-font1{
				font-size: 28rpx;
				color: #34302D;
				line-height: 40rpx;
				width: 570rpx;
			}
			.m-item-font2{
				font-size: 24rpx;
				color: #9A958F;
				line-height: 33rpx;
				margin-top: 10rpx;
			}
			.m-item-tip{
				display: inline-block;
				width: 60rpx;
				height: 30rpx;
				background: #D3A358;
				border-radius: 4rpx;
				font-size: 20rpx;
				color: #fff;
				text-align: center;
				line-height: 30rpx;
				vertical-align:text-top;
				margin-top: 5rpx;
				margin-right: 5rpx;
			}
		}
		.m-item-right{
			display: flex;
			justify-content: center;
			align-items: center;
			width: 104rpx;
			flex-shrink: 0;
			font-size: 30rpx;
			color: #9A958F;
			border-left: 1px solid #E5DCCD;
		}
	}
}
</style>
